package com.zaoniao.enstudy.domain.service;

import com.zaoniao.enstudy.domain.entity.ZaoWordExample;
import com.zaoniao.enstudy.domain.repository.ZaoWordExampleRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author llb666
 */
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ZaoWordExampleService {

    private final ZaoWordExampleRepository zaoWordExampleRepository;

    /**
     * 根据单词查询其相关联的例句.
     *
     * @param word 单词
     * @return 例句列表
     */
    @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class)
    public List<ZaoWordExample> getExamples(String word) {
        return zaoWordExampleRepository.getExamples(word);
    }
}
